import Opt from '@/components/dt/info/Opt.js'
import houseOpt from '@/biz/option/house.js'
import organizationOpt from '@/biz/option/organization.js'

let _this = null
class SearchOpt extends Opt {

  constructor(vm) {
    _this = vm
    super()
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
      organizationOpt.create({
        key: 'companyIds'
      }),
      houseOpt.create({
        to: (info) => {
          return {
            buildingId: info.housesId
          }
        }
      }),
      {
        title: '周期',
        group: [{
          key: 'year',
          placeholder: '请选择年',
          date: {
            type: 'year',
            clearable:false,
          },
          col:10,
          change:(val)=>{
            if(val.value!=''){
              _this.searchInfo.quarter = '01-03'
            }else{
              _this.searchInfo.quarter = ''
            }
          }
        }, {
          placeholder: '请选择季度',
          key:'quarter',
          col:14,
          select: {
            options:[
              {
                key:`01-03`,
                value:`第一季度 (1月至3月)`
              },
              {
                key:`04-06`,
                value:`第二季度 (4月至6月)`,
                tag:2
              },
              {
                key:`07-09`,
                value:`第三季度 (7月至9月)`,
                tag:3
              },
              {
                key:`10-12`,
                value:`第四季度 (10月至12月)`
              }
            ]
          }
        }]
      }
    ]
  }
}

export default SearchOpt